When uploading a new file, save to memcached directly after commit
authorBrian Wolff <bawolff+wn@gmail.com>
Sun, 6 Apr 2014 02:50:10 +0000 (23:50 -0300)
committerBrian Wolff <bawolff+wn@gmail.com>
Sun, 6 Apr 2014 02:30:22 +0000 (02:30 +0000)
Previously if an exception was thrown when creating the description
page, the old (negative) memcached entry would not be purged, and
the file would appear not to exist until 24 hours later.

This way, as soon as we have the image row committed to db, we
change the memcache entry, so memcache of image row always looks
like actual image row.

Bug: 32551
Change-Id: I9c260e9a4a1e0d6ade1771542dd834f969904cef

includes/filerepo/file/LocalFile.php

index 7a9e617..267dbd5 100644 (file)
@@ -1399,6 +1399,12 @@ class LocalFile extends File {
                #       to after $wikiPage->doEdit has been called.
                $dbw->commit( __METHOD__ );
 
+               # Save to memcache.
+               # We shall not saveToCache before the commit since otherwise
+               # in case of a rollback there is an usable file from memcached
+               # which in fact doesn't really exist (bug 24978)
+               $this->saveToCache();
+
                if ( $exists ) {
                        # Invalidate the cache for the description page
                        $descTitle->invalidateCache();
@@ -1431,11 +1437,6 @@ class LocalFile extends File {
 
                wfProfileOut( __METHOD__ . '-edit' );
 
-               # Save to cache and purge the squid
-               # We shall not saveToCache before the commit since otherwise
-               # in case of a rollback there is an usable file from memcached
-               # which in fact doesn't really exist (bug 24978)
-               $this->saveToCache();
 
                if ( $reupload ) {
                        # Delete old thumbnails